class OliveCamera extends GamePlayerCamera;

var transient bool bUseAlternateWatchLocation;
var transient Vector WatchLocationAlternate; //alternate camera location when dragging screen

var float PitchAngle;
var float YawAngle;

var transient bool bStartToResetCam;

var transient float RatioForResetCam;

simulated event UpdateCamera(float DeltaTime)
{
	if ( PCOwner.IsLocalPlayerController() || !bUseClientSideCameraUpdates || bDebugClientSideCamera )
	{
		DoUpdateCamera(DeltaTime);

		if (WorldInfo.NetMode == NM_Client && bShouldSendClientSideCameraUpdate)
		{
			PCOwner.ServerUpdateCamera(CameraCache.POV.Location, (CameraCache.POV.Rotation.Pitch & 65535) + ((CameraCache.POV.Rotation.Yaw & 65535) << 16));
			bShouldSendClientSideCameraUpdate = FALSE;
		}
	}
}

protected function GameCameraBase FindBestCameraType(Actor CameraTarget)
{
 //	local GameCameraBase BestCam;

	//// if not using a game-specific camera (i.e. not 'default'), we'll let the engine handle it
	//if (CameraStyle == 'default' || CameraStyle == 'FreeCam')
	//{
	//	BestCam = ThirdPersonCam;
	//}

	//if(BestCam == none)
	//	BestCam = super.FindBestCameraType(CameraTarget);

	return ThirdPersonCam;
}

function UpdateViewTarget(out TViewTarget OutVT, float DeltaTime)
{
	local Vector        Loc;   //location looking at
	local Rotator       Rot;
	local Pawn          TPawn;

	// Don't update outgoing viewtarget during an interpolation 
	if( PendingViewTarget.Target != None && OutVT == ViewTarget && BlendParams.bLockOutgoing )
	{
		return;
	}

	// Default FOV on viewtarget
	OutVT.POV.FOV = DefaultFOV;

	TPawn = Pawn(OutVT.Target);
	Loc = TPawn.Location;

	if(bStartToResetCam)
	{
		RatioForResetCam = FInterpConstantTo(RatioForResetCam, 1.0, DeltaTime, 3);
		//`log("Reset Camera WatchLocationAlternate"@WatchLocationAlternate@"Cam Loc"@Loc);
		Loc += (WatchLocationAlternate - Loc) * (1 - RatioForResetCam);
		if(RatioForResetCam >= 1.f)
		{
			RatioForResetCam = 0.f;
			bStartToResetCam = false;
			bUseAlternateWatchLocation = false;
			WatchLocationAlternate = Loc;
		}

	}
	else if (bUseAlternateWatchLocation)
	{
		Loc = WatchLocationAlternate;
	}
	Loc += (TPawn.Mesh.Translation - TPawn.default.Mesh.Translation) >> TPawn.Rotation;

	Rot.Pitch = (PitchAngle * DegToRad) * RadToUnrRot;
	Rot.Yaw = (YawAngle * DegToRad) * RadToUnrRot;
	Loc += FreeCamOffset >> Rot;

	OutVT.POV.Location = Loc - Vector(Rot) * FreeCamDistance;
	OutVT.POV.Rotation = Rot;
}

function ResetCameraToCenter()
{
	bStartToResetCam = true;
	RatioForResetCam= 0.f;
}

DefaultProperties
{   
	DefaultFOV=90.f
	FreeCamDistance=384.f
	CameraStyle=Watcher
	//ThirdPersonCameraClass=class'Olive3rdCamera'
	bUseAlternateWatchLocation = false;
	YawAngle=-45.f
	PitchAngle=-55.f
}
